package main

import (
	"flag"
	"fmt"
	"google.golang.org/grpc"
	"log"
	"mxshop_srvs/user_srv/handler"
	"mxshop_srvs/user_srv/proto"
	"net"
)

func main() {

	IP := flag.String("ip", "127.0.0.1", "ip地址")
	Port := flag.Int("port", 8001, "端口号")
	flag.Parse()

	server := grpc.NewServer()
	proto.RegisterUserServer(server, &handler.UserServer{})
	listen, err := net.Listen("tcp", fmt.Sprintf("%s:%d", *IP, *Port))
	if err != nil {
		log.Println("failed to listen:", err)
		return
	}
	fmt.Println(fmt.Sprintf("启动服务：%s:%d", *IP, *Port))
	err = server.Serve(listen)
	if err != nil {
		log.Println("failed to start grpc:", err)
	}
}
